<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>后台管理-登陆</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="__STATIC__/admin/lib/layui-v2.5.4/css/layui.css" media="all">
    <link rel="stylesheet" href="__STATIC__/admin/css/login.css">
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>
<body>
<div id="container">
    <div></div>
    <div class="admin-login-background">
        <div class="admin-header">
            <span>duleilei</span>
        </div>
        <form class="layui-form" action="">
            <div>
                <i class="layui-icon layui-icon-username admin-icon"></i>
                <input type="text" name="username" placeholder="请输入用户名" autocomplete="off" class="layui-input admin-input admin-input-username" value="">
            </div>
            <div>
                <i class="layui-icon layui-icon-password admin-icon"></i>
                <input type="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input admin-input" value="">
            </div>
            <div>
                <input type="text" name="captcha" placeholder="请输入验证码" autocomplete="off" class="layui-input admin-input admin-input-verify input-val" value="">
                <img src="{:captcha_src()}" alt="captcha" width="90" height="35" class="admin-captcha" onclick="reloadTim()" id="yzm"/>
            </div>
            <button class="layui-btn admin-button" lay-submit="" lay-filter="login">登 陆</button>
        </form>
    </div>
</div>
<script src="__STATIC__/admin/lib/layui-v2.5.4/layui.js" charset="utf-8"></script>
<script src="__STATIC__/admin/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script src="__STATIC__/admin/js/common.js" charset="utf-8"></script>
<script src="__STATIC__/admin/js/login.js?v9"></script>
<script type="text/javascript">
    function reloadTim() {
        $("#yzm").attr('src',"{:captcha_src()}?rand="+Math.random());
    }
    var show_num = [];

    layui.use(['form'], function () {

        var form = layui.form,
            layer = layui.layer;
        // 登录过期的时候，跳出ifram框架
        if (top.location != self.location) top.location = self.location;
        // 进行登录操作
        form.on('submit(login)', function (data) {
            data = data.field;
            if (data.username == '') {
                layer.msg('用户名不能为空');
                return false;
            }
            if (data.password == '') {
                layer.msg('密码不能为空');
                return false;
            }


            if (data.captcha == '') {
                layer.msg('验证码不能为空');
                return false;
            }
            $(".input-val").val('');

            $.ajax({
                url:"/admin/login/check",
                data,
                type:"POST",
                success(res){
                    if(res.status == 1){
                        layer.msg('登录成功', function () {
                            window.location = '/admin/index/index';
                        });
                    }else{
                        layer.msg(res.message,function(){
                            $("#yzm").attr('src',"{:captcha_src()}?rand="+Math.random());
                        });
                        return false;
                    }
                }
            })
            return false;
        });
    });
</script>
</body>
</html>
